Skip to content

Conversation

@andrei-marinica
Copy link
Contributor

No description provided.

@andrei-marinica andrei-marinica marked this pull request as draft July 7, 2025 22:28
@github-actions
Copy link

github-actions bot commented Jul 7, 2025

Coverage Summary

Totals

Count Covered %
Lines 3878 2169 55.93
Regions 5332 3448 64.67
Functions 512 267 52.15
Instantiations 1536 463 30.14

Files

Expand
File Lines Regions Functions Instantiations
/auction-mock/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/auction-mock/src/lib.rs 87.93% 83.45% 87.50% 43.75%
/auction-mock/src/storage.rs 0.00% 0.00% 0.00% 0.00%
/interactor/src/deleg_interactor.rs 0.00% 0.00% 0.00% 0.00%
/interactor/src/deleg_interactor_admin.rs 0.00% 0.00% 0.00% 0.00%
/interactor/src/deleg_interactor_config.rs 0.00% 0.00% 0.00% 0.00%
/interactor/src/deleg_interactor_stats.rs 0.00% 0.00% 0.00% 0.00%
/interactor/src/deleg_interactor_user.rs 0.00% 0.00% 0.00% 0.00%
/interactor/src/latest_proxy.rs 0.00% 0.00% 0.00% 0.00%
/latest/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/latest/src/auction_proxy.rs 75.25% 71.21% 70.00% 18.42%
/latest/src/delegation_main.rs 62.07% 71.19% 60.00% 15.00%
/latest/src/events.rs 0.00% 0.00% 0.00% 0.00%
/latest/src/governance.rs 0.00% 0.00% 0.00% 0.00%
/latest/src/node_activation.rs 78.31% 78.26% 84.00% 21.00%
/latest/src/reset_checkpoint_endpoints.rs 87.50% 91.32% 81.82% 20.45%
/latest/src/reset_checkpoint_state.rs 66.67% 66.67% 50.00% 12.50%
/latest/src/reset_checkpoint_types.rs 31.25% 23.33% 10.00% 3.23%
/latest/src/rewards_endpoints.rs 95.65% 96.23% 66.67% 16.67%
/latest/src/rewards_state.rs 88.64% 88.82% 80.00% 20.00%
/latest/src/settings.rs 88.89% 93.33% 75.00% 18.75%
/latest/src/user_stake_dust_cleanup.rs 0.00% 0.00% 0.00% 0.00%
/latest/src/user_stake_endpoints.rs 94.92% 97.71% 87.50% 21.88%
/latest/src/user_stake_state.rs 97.26% 98.73% 87.50% 21.88%
/latest/tests/latest_scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/latest/tests/latest_scenario_rs_test.rs 96.88% 96.88% 96.55% 96.55%
/node-storage/src/node_config.rs 60.61% 61.15% 55.56% 13.89%
/node-storage/src/types/bls_key.rs 0.00% 0.00% 0.00% 0.00%
/node-storage/src/types/bls_sig.rs 0.00% 0.00% 0.00% 0.00%
/node-storage/src/types/node_state.rs 46.67% 46.67% 20.00% 6.25%
/user-fund-storage/src/fund_module.rs 89.97% 90.38% 92.86% 55.16%
/user-fund-storage/src/fund_transf_module.rs 85.42% 87.07% 84.21% 32.11%
/user-fund-storage/src/fund_view_module.rs 78.26% 84.40% 89.29% 22.32%
/user-fund-storage/src/types/affected_user_id_vec.rs 100.00% 100.00% 100.00% 100.00%
/user-fund-storage/src/types/fund_item.rs 81.82% 71.43% 33.33% 13.33%
/user-fund-storage/src/types/fund_list_info.rs 71.43% 66.67% 33.33% 21.43%
/user-fund-storage/src/types/fund_type.rs 39.29% 41.38% 18.18% 5.88%
/user-fund-storage/src/types/partition_dedup.rs 100.00% 97.87% 100.00% 100.00%
/user-fund-storage/src/user_data.rs 34.15% 37.84% 40.00% 10.00%
/user-fund-storage/tests/fund_module_check.rs 89.47% 90.54% 100.00% 66.67%
/user-fund-storage/tests/test_high_level.rs 100.00% 100.00% 100.00% 100.00%
/user-fund-storage/tests/test_low_level.rs 100.00% 100.00% 100.00% 100.00%

@github-actions
Copy link

github-actions bot commented Jul 7, 2025

Contract comparison - from 2f10986 to af0c61f

Path                                                                                             size                  has-allocator                     has-format
auction-mock.wasm 5748 false without message
delegation_latest_full.wasm 36391 false without message
delegation_latest_update.wasm 36123 false without message

⚠️ Could not download the report for the base branch. Displaying only the report for the current branch. ⚠️

@andrei-marinica andrei-marinica marked this pull request as ready for review January 9, 2026 15:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds governance voting functionality to the delegation contract, allowing delegators to vote on governance proposals using their active stake. The changes also update the multiversx-sc framework from version 0.58.0 to 0.60.0 and bump the contract version from 0.5.8 to 0.5.9.

Key changes:

  • New governance module with delegateVote and getVotingPower endpoints
  • Framework upgrade from 0.58.0 to 0.60.0 across all crates
  • Refactoring to pass references instead of owned values in fund view methods
  • Migration from static to const for compile-time constants

Reviewed changes

Copilot reviewed 43 out of 55 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
latest/src/governance.rs New module implementing vote delegation to governance SC
latest/src/delegation_main.rs Integrates governance module into main contract
latest/src/settings.rs Converts static constants to const for better semantics
user-fund-storage/src/fund_view_module.rs Optimizes parameter passing by using references
user-fund-storage/Cargo.toml Updates framework dependency to 0.60.0
node-storage/Cargo.toml Updates framework dependency to 0.60.0
latest/Cargo.toml Updates framework to 0.60.0 and version to 0.5.9
latest/wasm-delegation_latest_update/src/lib.rs Adds delegateVote and getVotingPower endpoint exports
latest/wasm-delegation_latest_full/src/lib.rs Adds delegateVote and getVotingPower endpoint exports
latest/tests/latest_scenario_rs_test.rs Fixes test attribute ordering and updates test names
latest/tests/latest_scenario_go_test.rs Updates test names for version scenarios
latest/scenarios/version_full.scen.json Updates expected version output to 0.5.9
v0_5_9_update/output/delegation_v0_5_9_update.wasm Generated WASM binary for update contract
v0_5_9_update/output/delegation_v0_5_9_update.abi.json Generated ABI with new governance endpoints
v0_5_9_full/output/delegation_v0_5_9_full.wasm Generated WASM binary for full contract

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +11 to +26
#[endpoint(delegateVote)]
fn delegate_vote(&self, proposal_to_vote: u64, vote: ManagedBuffer) {
let voter = self.blockchain().get_caller();

let staked_balance = self.get_user_stake_of_type_by_address(&voter, FundType::Active);

self.tx()
.to(GovernanceSystemSCAddress)
.typed(GovernanceSCProxy)
.delegate_vote(proposal_to_vote, &vote, &voter, &staked_balance)
.callback(
self.callbacks()
.delegate_vote_callback(&voter, proposal_to_vote, &vote),
)
.async_call_and_exit();
}
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing input validation for the delegateVote endpoint. The function does not validate that the user has any active stake before making the external call. A user with zero active stake could still trigger an async call to the governance contract, wasting gas and potentially causing unexpected behavior.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contract was tested with voting with 0.

@andrei-marinica andrei-marinica merged commit 3f50c16 into master Jan 9, 2026
12 checks passed
@andrei-marinica andrei-marinica deleted the governance branch January 9, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants